﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UFSoft.UBF.Business;
using UFSoft.UBF.Eventing;
using UFIDA.U9.SM.Ship;
using UFIDA.U9.PM.PO;
using UFSoft.UBF.PL;
using UFIDA.U9.PM.Rcv;
using UFIDA.U9.SM.RMA;
using UFIDA.U9.SM.SO;
using UFIDA.U9.CBO.SCM.Customer;


namespace UFIDA.U9.Cust.U9Demo.PlugBE
{
    /// <summary>
    /// 培训代码示例
    /// 发货单
    /// 可以修改出货单、出货单行的字段
    /// </summary>
    class ShipUpdatingExtend : IEventSubscriber
    {
        //配置XX.sub.xml文件放置到portal/bin下，dll文件放置到portal/ApplicationServer/Libs下
        public void Notify(params object[] args)
        {
            if (args != null && args.Length != 0 && args[0] is EntityEvent)
            {
                BusinessEntity.EntityKey key = ((EntityEvent)args[0]).EntityKey;
                UFIDA.U9.SM.Ship.Ship ship = key.GetEntity() as UFIDA.U9.SM.Ship.Ship;
                if (ship == null)
                    return;
                //可以修改出货单、出货单行的字段
                //using (ISession session = Session.Open())
                //{
                //    foreach (ShipLine line in ship.ShipLines)
                //    {
                //        UFIDA.U9.Cust.Demo.SalesPromotionBE.SalesPromotionMaster
                //            saleMaster = SalesPromotionMaster.Finder.Find("SrcDoc='" + line.SrcDocNo + "' and DocLineNo='" + line.SrcDocLineNo + "'");
                //        if (saleMaster != null)
                //        {
                //            saleMaster.IsSalesMoney = line.TotalMoneyTC;
                           
                //        }
                //    }
                //    session.Commit();
                  
                //}
                //ship.DescFlexField.PrivateDescSeg1 = "1";
            }
        }

     
    }
}
